Repository navigation
Conversation
…ignal A backlog that is already in the queue produces no further insert notifications, so after reading one batch the consumer slept until the poll interval elapsed: a queue of N messages took ~N/batch * pollInterval to drain.
This was referenced Oct 7, 2026
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #19.
A backlog that is already in the queue produces no further insert notifications, so after reading one batch the consumer waited for the poll timer: a queue of
Nmessages took~N / batch × pollIntervalto drain.Change
Internal\consume(): after a batch that came back full (count === $config->batch), push the next poll request right away. A partial or empty batch does not re-poll, so idle behaviour and query count are unchanged. A consumer stopped from the handler ($ctrl->stop()) is respected:$polls->isComplete().Test
testConsumerDrainsBacklogWithoutWaitingForPollInterval: 25 messages already in the queue,batch: 10,pollInterval: 10 s; all must be consumed within 2 s.Amp\CancelledException(the 2nd and 3rd batches wait 10 s and 20 s);Edge cases checked with a stress harness (real Postgres, pgmq 1.11.1 and 1.13.0)
batch: 10,pollInterval: 10 spollInterval: 2 spollInterval: 1 s² When several separate transactions insert into the queue within the 30 ms notify throttle window, the last of them get no notification (pgmq notifies on the leading edge only) and wait for the poll timer. This happens with or without this change; details in thesis-php/message-bus#4.
Checks (run locally in the project's Docker images)
fixer-check,rector-check,composer-validate,composer-normalize-check,deps-analyze: ✅¹ Two PHP deprecations from
amphp/amp(lowest version) on PHP 8.5:Increment on non-numeric stringinFutureState.php:70. They are present on0.1.xas well, and the exit code is 0.